import com.dmotiko.bolacua.*
import com.dmotiko.general.*
import com.dmotiko.util.*

class PhotoPopUpPic
extends MovieLoaderClip {
	
	public static var NEXT_PHOTO:String = "photopopuppic_nextphoto";
	public static var PREV_PHOTO:String = "photopopuppic_prevphoto";
	public static var CLOSE:String = "photopopuppic_close";
	
	private var mcPrev:MovieClip;
	private var mcNext:MovieClip;
	private var mcClose:MovieClip;
	private var txtTitle:TextField;
	private var txtDescription:TextField;
	private var mcLoader:LoaderBolacua;
			
	private function PhotoPopUpPic() {
		super();
	}
	
	private function initClip():Void {
		super.initClip();
		var root:PhotoPopUpPic = this;
		mcPrev._alpha = 50;
		mcNext._alpha = 50;
		mcNext.onRollOver = mcPrev.onRollOver = function() {
			this._alpha = 100;
		}
		mcNext.onRollOut = mcPrev.onRollOut = function() {
			this._alpha = 50;
		}
		
		mcPrev.onRelease = function() {
			root.dispatchEvent( { target: root, type: PREV_PHOTO });
		}
		mcNext.onRelease = function() {
			root.dispatchEvent( { target: root, type: NEXT_PHOTO });
		}
		mcClose.onRelease = function() {
			root.dispatchEvent( { target: root, type: CLOSE });
		}
		txtTitle.autoSize = "left";
		txtTitle.text = "";
		txtDescription.text = "";
	}
	
	private function refreshData():Void {
		txtTitle.text = data.getTitle();
		txtDescription.text = data.getDescription();
		loadContent(data.getSrc());
	}
	
	public function onLoadProgress(target, loaded, total):Void {
		super.onLoadProgress(target, loaded, total);
		mcLoader._visible = true;
		mcLoader.setPos( Math.round( loaded * 100 / total) );
	}
	
	public function onLoadInit(target):Void {
		mcLoader._visible = false;
		mcLoader.setPos(0);
		super.onLoadInit(target);
		MovieEffects.fadeIn();
		if (target.fade) target.fade.stopEffect();
		target._alpha = 0;
		target.fade = target.fadeIn( { rate: 5 } );
	}
	
}